<!DOCTYPE html>
<!--suppress ThymeleafVariablesResolveInspection-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="Responsive Admin Dashboard Template">
        <meta name="keywords" content="admin,dashboard">
        <meta name="author" content="skcats">
		<title></title>
		<link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all" />
        <link th:href="@{/assets/plugins/bootstrap/css/bootstrap.min.css}" rel="stylesheet">
        <link th:href="@{/assets/plugins/font-awesome/css/font-awesome.min.css}" rel="stylesheet">
        <link th:href="@{/assets/css/custom.css}" rel="stylesheet">
	</head>
	<style>
    .layui-table-page {
        text-align: center;
    }

    .utable .layui-laypage .layui-laypage-curr .layui-laypage-em {
        background-color: #1E9FFF;
    }
    .layui-form-item{margin-top: 20px;}
    .layui-form-label{width: 80px;}
    .layui-table-view thead th {
        text-align: center;
        font-weight: bold;
    }
    .layui-table-view tbody td {
        text-align: center;
    }
    .layui-form-select dl { max-height:200px; }
	</style>
<body>
<!--数据表格样式及附件-->	
    <script type="text/html" id="bar">

        <a id="ann" class="layui-btn layui-btn-warm layui-btn-xs" lay-event="look">
            <i class="layui-icon">&#xe642;</i>查看成绩
        </a>

    <a id="upd" class="layui-btn layui-btn-xs" lay-event="upd">
        <i class="layui-icon">&#xe642;</i>编辑
    </a>

    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">
        <i class="layui-icon">&#xe640;</i>丢弃
    </a>
	</script>

<!--数据表格样式及附件-->
<script id="toolbarDemo" type="text/html">
    <div class="layui-btn-container">
        <button id="add" class="layui-btn layui-btn-sm" onclick="add()"><i class="layui-icon">&#xe654;</i>成绩录入</button>
    </div>
</script>


<!--搜索栏-->
<form class="layui-form">

    <div class="layui-inline">
        <label class="layui-form-label" style="width:100px">课程类别</label>
        <div class="layui-input-inline">
            <select id="testtype" style="height: 35px;width: 120px;" name="testtype" lay-filter="mySelect">
                <option value="">选择类型</option>
                <option value="笔试">笔试</option>
                <option value="机试">机试</option>
                <option value="模拟面试">模拟面试</option>
            </select>
        </div>
    </div>

    <div class="layui-inline">
        <label class="layui-form-label" style="width:100px">学期名称</label>
        <div class="layui-input-inline">
            <select id="termid" style="height: 35px;width: 120px"  name="termid" lay-filter="mySelect">
                <option value="">选择学期</option>
                <option th:each="term:${terms}"th:value="${term.termid}" th:text="${term.termname}"></option>
            </select>
        </div>
    </div>

    <div class="layui-inline">
        <label class="layui-form-label" style="width:100px">班级名称</label>
        <div class="layui-input-inline">
            <select id="classid"name="classid"style="height: 35px;width: 120px;" lay-filter="mySelect">
                <option value="">请选择班级</option>
                <option th:each="class:${calsss}"th:value="${class.classid}" th:text="${class.classname}"></option>
            </select>
        </div>
    </div>

    <div class="layui-inline" style="margin-left: 20px">
        <button id="ck" type="button" class="btn btn-info btn-addon"><i class="fa fa-spin fa-refresh"></i>查找</button>
    </div>
</form>


<!--数据表格  数据表格使用的是方法渲染-->
<div class="utable">
<table class="layui-table"
       lay-data="{width:1250,height:520, url:'/classscore/listdata', page:true, id:'tab',toolbar: '#toolbarDemo'}"
       lay-filter="tab">
    <thead>
    <tr>
        <th lay-data="{field:'cscoreid', width:80, sort: true}">ID</th>
        <th lay-data="{field:'testtype'}">考试类别</th>
        <th lay-data="{field:'className'}">班级名称</th>
        <th lay-data="{field:'courseName'}">课程名称</th>
        <th lay-data="{field:'termname'}">学期名称</th>
        <th lay-data="{field:'emp_Name'}">录入人员</th>
        <th lay-data="{field:'scoreTime'}">考试时间</th>
        <th lay-data="{field:'remark', edit: 'false'}">说明</th>
        <th lay-data="{fixed: 'right', title:'操作', toolbar: '#bar', width:250}"></th>
    </tr>
    </thead>
</table>
</div>
</body>
<script th:src="@{/assets/plugins/jquery/jquery-3.1.0.min.js}"></script>
<script th:src="@{/layui/layui.js}"></script>
<script type="text/javascript" th:inline="none">

    function add(){
        //iframe窗
        layer.open({
            type: 2,
            title: '班级成绩录入',
            maxmin: true, //开启最大化最小化a按钮
            area: ['500px', '400px'],
            content: ['/classscore/toadd']//这是链接你的页面地址 url
        });
    }

    layui.use('table', function () {
        var table = layui.table;


        //模糊
        $("#ck").on('click',function(){
            var testtype=$("#testtype").val();
            var termid=$("#termid").val();
            var classid=$("#classid").val();
            table.reload('tab', {
                where: { //设定异步数据接口的额外参数，任意设
                    testtype: testtype,
                    termid: termid,
                    classid:classid,
                }
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });




        //监听行工具事件
        table.on('tool(tab)', function (obj) {
            var data = obj.data;
            //console.log(obj)
            if (obj.event === 'del') {
                layer.confirm('真的删除么?', function (index) {
                    obj.del();
                    layer.close(index);
                    $.ajax({
                        url: '/classscore/del',
                        type: 'post',
                        data: {
                            id:data.cscoreid
                        },
                        dataType: 'json',
                        success:function(data){
                            if(data){
                                layer.msg(JSON.stringify("删除成功"));
                                }else {

                                }
                        },
                    })
                });
            }else if (obj.event == 'upd') {//修改

                layer.open({
                    type: 2,
                    title: '班级成绩修改',
                    maxmin: true, //开启最大化最小化a按钮
                    area: ['500px', '400px'],
                    content: ['/classscore/toupd?id='+data.cscoreid]//这是链接你的页面地址 url
                });

            }else if (obj.event == 'look') {//查看
                document.location.href="/classscore/look?scoreid="+data.cscoreid;
            }

        })


    });
</script>
</html>